package mil.af.amc.adpetracker.util.security;

import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.security.ConfigAttributeDefinition;
import org.springframework.security.ConfigAttributeEditor;
import org.springframework.security.intercept.web.FilterInvocation;
import org.springframework.security.intercept.web.FilterInvocationDefinitionSource;

import java.net.MalformedURLException;
import java.util.Collection;

/**
 * Please Fill in this Javadoc
 *
 * @author TSgt Jason Ferguson
 */

public class SecureResourceFilter implements FilterInvocationDefinitionSource {

    public ConfigAttributeDefinition getAttributes(Object filter) throws IllegalArgumentException {

        FilterInvocation invocation = (FilterInvocation) filter;
        String url = invocation.getRequestUrl();

        Resource resource = null;
        try {
            resource = new UrlResource(url);
        } catch (MalformedURLException e) {

        }

        if (resource==null) {
            return null;
        } else {
            ConfigAttributeEditor editor = new ConfigAttributeEditor();
            //List<Role> roles = resource.
        }

        throw new UnsupportedOperationException();
    }

    public Collection getConfigAttributeDefinitions() {
        return null;
    }

    public boolean supports(Class aClass) {
        return true;
    }
}
